/**
 * 分页
 */
export default {
  functional: true,
  name: 'Pagination',
  props: {
    total: {
      type: Number,
      default: 0
    },
    pagination: {
      type: Object,
      default: () => {
        return {
          limit: 10,
          currentPage: 1,
        }
      }
    }
  },
  render(h, ctx) {
    const { props, listeners } = ctx
    const { total, pagination } = props
    const { change } = listeners
    // 切换页数
    const changePage = (currentPage) => {
      change({ pagination: { currentPage, limit: pagination.limit } })
    }

    return (
      <el-pagination
        background
        total={total}
        page-size={pagination.limit}
        current-page={pagination.currentPage}
        onCurrent-change={changePage}
      />
    )
  }
}